package com.phoxell;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Agent{
	static Pattern p=Pattern.compile("xync/(\\d+[.]\\d+)\\s*"+
			"[(]((\\w|\\s|[.])+)[)]\\s*serialnumber=(\\w+),\\s*"+
			"firmware=(\\d+)[.](\\d+)",Pattern.CASE_INSENSITIVE);
	public Agent(String c) throws Exception{
		Matcher m=p.matcher(c);
		if(m.find()){
			version=m.group(1);
			os=m.group(2);
			serial=m.group(4);
			int major=Integer.parseInt(m.group(5));
			int minor=Integer.parseInt(m.group(6));
			firmware=(short)((major<<8)+minor);
			System.out.println(m.group());
		}else throw new Exception();
	};
	public String version;
	public String os;
	public String serial;
	public short firmware;
}